package com.wk.springboot.spring.config;

import com.wk.springboot.spring.bean.Color;
import com.wk.springboot.spring.bean.Person;
import com.wk.springboot.spring.factoryBean.MyFactoryBean;
import com.wk.springboot.spring.imports.AnimalBeanConfig;
import com.wk.springboot.spring.imports.MyImportBeanDefinitionRegistrar;
import com.wk.springboot.spring.imports.MyImportSelector;
import com.wk.springboot.spring.service.MyService;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.*;

/**
 * @User admin
 * @Date 2020/11/20 11:15
 **/
@Configuration
@Import({AnimalBeanConfig.class, MyImportSelector.class, MyImportBeanDefinitionRegistrar.class})
@ComponentScan(value = "com.wk.springboot.spring")
public class ConfigBean {

    MyService myService;

    @Bean(value = "person",initMethod = "initMethod",destroyMethod = "destroyMethod")
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public Person getPerson(){
        Person person = new Person();
        person.setAge(12);
        person.setName("张三");
        return person;
    }


    @Bean
    public FactoryBean<Color> factoryBean(){
        return new MyFactoryBean();
    }
}
